﻿/**************************************************************************************************************
 * Class name:  T_SharpCompress.cs
 * Description: SharpCompress 测试（压缩、解压缩）
 * Author:      Zhenda Jiang
 * Create:      2012-11-05 Monday 14:30:11
 * Update:      2012-11-05 Monday 14:30:11
 **************************************************************************************************************/

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SharpCompress.Common;
using SharpCompress.Reader;

namespace Web {

  public partial class T_SharpCompress : System.Web.UI.Page {

    protected void Page_Load(object sender, EventArgs e) {

      string path = string.Empty;

      path = Server.MapPath("/temp");

      if (!Directory.Exists(path)) {
        Directory.CreateDirectory(path);
      }

      using (Stream stream = File.OpenRead(Server.MapPath("/zip/HTML5.zip"))) {
        var reader = ReaderFactory.Open(stream);

        while (reader.MoveToNextEntry()) {
          if (!reader.Entry.IsDirectory) {
            Response.Write(reader.Entry.FilePath + "<br />");
            reader.WriteEntryToDirectory(path, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
          }
        }
      }
    }
  }
}